<?php

namespace app\common\model;

//use think\Model;

class OutRecordModel extends BaseModel{

	protected $table = 'tp_out_record';

	/*
	添加记录
	 */
	public function addRecord($uid,$wid,$cid,$amount,$fee,$address,$tag,$is_wu){
		$data = [
			'uid'=>$uid,
			'cid'=>$cid,
			'wid'=>$wid,
			'amount'=>$amount,
			'fee'=>$fee,
			'tag'=>$tag,
			'left_amount'=>$amount-$fee,
			'address'=>$address,
			'status'=>0,
			'remark'=>'待审核',
			'is_wu'=>$is_wu,
			'date'=>$this->getDate()
		];
		$res = $this->insertGetId($data);
		return $res;
	}

	/*
	获取记录
	 */
	public function getRecord($uid){
		$data = $this->alias('r')
						->join('tp_coin_wallet w','w.id=r.wid','LEFT')
						->join('tp_coin c','c.id=r.cid','LEFT')
						->where('r.uid',$uid)
						->order('r.id desc')
						->field('r.*,c.name coin_name,w.name wallet_name')
						->select();
		return $data;
	}

	/*
	待审核订单
	 */
	public function underCheck($uid,$cid){
		$data = $this->where('uid',$uid)->where('status',0)->where('cid',$cid)->find();
		if($data){
			return true;
		} else {
			return false;
		}
	}
}